package com.ivy.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ivy.dao.FriendDao;
import com.ivy.dao.UserDao;
import com.ivy.dao.impl.FriendDaoImpl;
import com.ivy.dao.impl.UserDaoImpl;
import com.ivy.entity.Friend;
import com.ivy.entity.User;
import com.ivy.service.FriendService;

public class FriendServiceImpl implements FriendService{
	private FriendDao friendDao = new FriendDaoImpl();
	private UserDao userDao = new UserDaoImpl();
	@Override
	public void addFriend(Friend friend) {
		
		friendDao.insert(friend);

	}

	@Override
	public List<User> findFriendByOwner_tel(String owner_tel) {
		List<Friend> friends = friendDao.findFriendByTelephone(owner_tel);
		List<User> users = new ArrayList<User>();
		for(Friend friend : friends) {
			User user = userDao.findUserByTelephone(friend.getFriend_tel());
			user.toString();
			users.add(user);
		}
		return users;
	}

}
